package base;

import java.util.HashSet;
import java.util.Set;

class Employee{
	private int id;
	private String name;
	
	public Employee(){
		id=-1;
		name= null;
	}
	
	public Employee(int id, String name){
		this.id = id;
		this.name = name;
	}
	
	@Override
	public boolean equals(Object obj){
		if(obj==null){
			return false;
		}else{
			if(this==obj){
				return true;
			}else{
				if(obj instanceof Employee){
					Employee another = (Employee)obj;
					if(this.id== another.id && this.name.equals(another.name)){
						return true;
					}else{
						return false;
					}
				}else{
					return false;
				}
			}
		}
	}
	
	@Override
	public int hashCode(){
		int primaryKey = 31;
		int result = 1;
		result = result*primaryKey+this.id;
		result = result*primaryKey+this.name.hashCode();
		return result;
	}
}
public class EmployeeSet {

	
	public static void main(String[] args) {
           Employee e1= new Employee(1,"b");
           Employee e2= new Employee(1,"a");
           if(e1.equals(e2)){
        	   System.out.println("Equal");
           }
           Set<Employee> empSet = new HashSet<Employee>();
           empSet.add(e1);
           empSet.add(e2);
           System.out.println("Size of set is "+empSet.size());
           
	}

}
